package com.asiainfo.web.controller;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.asiainfo.bean.AuthorityBean;
import com.asiainfo.service.AuthorityService;


/**
 * 资源控制器
 * @author luhf
 * @date Jan 7, 2013 12:44:51 PM
 */
@Controller
@RequestMapping(value="/authority")
public class AuthorityController{
	
	private static final Logger log=LoggerFactory.getLogger(AuthorityController.class);
	
	@Autowired
	@Qualifier("impl.authorityServiceImpl")
	private AuthorityService authorityService;
	
	/***********************visit******************************/
	@RequestMapping(value="/listIndex")
	public String listIndex(){
		log.debug("AuthorityController::listIndex::资源展示页面");
		return "/authority/listIndex";
	}
	
	@RequestMapping(value="/addIndex")
	public String addIndex(){
		log.debug("AuthorityController::addIndex::资源添加页面");
		return "/authority/addIndex";
	}
	
	@RequestMapping(value="/deleteIndex")
	public String deleteIndex(){
		log.debug("AuthorityController::deleteIndex::资源删除页面");
		return "/authority/deleteIndex";
	}
	
	@RequestMapping(value="/updateIndex")
	public String updateIndex(){
		log.debug("AuthorityController::updateIndex::资源修改页面");
		return "/authority/updateIndex";
	}
	
	
	/***********************handle******************************/
	@RequestMapping(value="/list",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> list(int page, int rows){
		log.debug("AuthorityController::list::发送数据");
		return authorityService.getAuthorityList(rows,page);
	}
	
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> add(@RequestBody AuthorityBean authorityBean){
		log.debug("AuthorityController::add::返回新增状态");
		return authorityService.addAuthority(authorityBean);
	}
}
